﻿using Medianamik.Client.Data;
using Medianamik.Core;
using Medianamik.Core.DAL;
using Medianamik.Core.DAL.Repositories;
using Medianamik.UI.Web.MVP.Presentation;
using Medianamik.UI.Web.Shop.Data;
using Medianamik.UI.Web.Shop.Data.Repositories;
using Medianamik.UI.Web.Shop.Services;
using Medianamik.UI.Web.Shop.Presentation.Presenters;

namespace Medianamik.UI.Web.Shop.Container.Registries
{
    public class DefaultShopRegistry : StructureMap.Configuration.DSL.Registry
    {
        public DefaultShopRegistry()
        {
            ForRequestedType<INodeMapper>()
                .TheDefaultIsConcreteType<NodeMapper>();

            #region Categories

            ForRequestedType<ICategoryRepository<Category>>()
                .TheDefaultIsConcreteType<CategoryRepository>();
            ForRequestedType<ModulePresenter<ICategories>>()
                .TheDefaultIsConcreteType<CategoryListPresenter<Category, ICategories>>();

            #endregion

            #region Products

            ForRequestedType<ModulePresenter<IProducts>>()
                .TheDefaultIsConcreteType<ProductListPresenter>();
            ForRequestedType<IProductRepository<BaseProduct>>()
                .TheDefaultIsConcreteType<ProductRepository>();
            ForRequestedType<IProducts>()
                 .TheDefaultIsConcreteType<ShopProducts>();
            ForRequestedType<IProductsInCategoriesRepository<ProductsInCategories>>()
                 .TheDefaultIsConcreteType<ProductsInCategoriesRepository<ProductsInCategoriesCollection, ProductsInCategories>>();

            #endregion

            #region Brands

            ForRequestedType<ModulePresenter<IBrands>>()
                .TheDefaultIsConcreteType<BrandListPresenter<Brand, IBrands>>();
            ForRequestedType<IBrandRepository<Brand>>()
                .TheDefaultIsConcreteType<BrandRepository<BrandCollection, Brand>>();

            #endregion

            #region ModelGroups

            ForRequestedType<ModulePresenter<IModelGroups>>()
                .TheDefaultIsConcreteType<ModelGroupListPresenter<ModelGroup, IModelGroups>>();
            ForRequestedType<IModelGroupRepository<ModelGroup>>()
                .TheDefaultIsConcreteType<ModelGroupRepository>();

            #endregion

            #region Models

            ForRequestedType<ModulePresenter<IModels>>()
                .TheDefaultIsConcreteType<ModelListPresenter<Model, IModels>>();
            ForRequestedType<IModelRepository<Model>>()
                .TheDefaultIsConcreteType<ModelRepository>();

            #endregion

            #region ShippingBase

            ForRequestedType<ModulePresenter<IShippingList>>()
                .TheDefaultIsConcreteType<ShippingListPresenter<ShippingBase, IShippingList>>();
            ForRequestedType<IShippingBaseRepository<ShippingBase>>()
                .TheDefaultIsConcreteType<ShippingBaseRepository<ShippingBaseCollection, ShippingBase>>();

            #endregion

            #region Payment Providers

            ForRequestedType<ModulePresenter<IPaymentProviderList>>()
                .TheDefaultIsConcreteType<PaymentProviderListPresenter<PaymentProviderBase,IPaymentProviderList>>();
            ForRequestedType<IPaymentProviderBaseRepository<PaymentProviderBase>>()
                .TheDefaultIsConcreteType<PaymentProviderBaseRepository<PaymentProviderBaseCollection, PaymentProviderBase>>();

            #endregion

            #region Order

            ForRequestedType<IOrderRepository<Order, OrderItem>>()
                .TheDefaultIsConcreteType<OrderRepository<OrderCollection, Order, OrderItem>>();
            ForRequestedType<IOrderItemRepository<OrderItem>>()
                .TheDefaultIsConcreteType<OrderItemRepository<OrderItemCollection, OrderItem>>();
            ForRequestedType<ModulePresenter<IOrders>>()
                .TheDefaultIsConcreteType<OrderListPresenter>();

            #endregion

            #region RegionAndTaxe

            ForRequestedType<IRegionAndTaxRepository<BaseType>>()
                .TheDefaultIsConcreteType<RegionAndTaxRepository<BaseTypeCollection, BaseType>>();
            ForRequestedType<IRegionRepository<Region>>()
                .TheDefaultIsConcreteType<RegionRepository>();
            ForRequestedType<ITaxRepository<Tax>>()
                .TheDefaultIsConcreteType<TaxRepository>();
            ForRequestedType<IRegionAndTaxService>()
                .TheDefaultIsConcreteType<RegionAndTaxService<Tax, Region>>();
            ForRequestedType<ModulePresenter<IRegionAndTaxes>>()
                .TheDefaultIsConcreteType<RegionAndTaxeListPresenter<BaseProduct, IRegionAndTaxes>>();

            #endregion

            #region Company

            ForRequestedType<ModulePresenter<ICompanyList>>()
                .TheDefaultIsConcreteType<CompanyListPresenter<Company, ICompanyList>>();
            ForRequestedType<ICompanyRepository<Company>>()
                .TheDefaultIsConcreteType<CompanyRepository<CompanyCollection, Company>>();

            #endregion

            #region Address
            ForRequestedType<IAddressRecordRepository>()
                .TheDefaultIsConcreteType<AddressRecordRepository>();
            ForRequestedType<IAddressRepository<Address>>()
                .TheDefaultIsConcreteType<AddressRepository>();
            #endregion

            ForRequestedType<IClientProfileRepository<ClientProfile>>()
                .TheDefaultIsConcreteType<ClientProfileRepository>();

            ForRequestedType<IMedianamikRepository<Node>>().TheDefaultIsConcreteType<NodeRepository>();

            ForRequestedType<ModulePresenter<IAttributeTypeListView>>().TheDefaultIsConcreteType
                <AttributeTypeListPresenter<IAttributeTypeListView>>();
            ForRequestedType<ModulePresenter<IEditAttributeTypeView>>().TheDefaultIsConcreteType
                <EditAttributeTypePresenter<IEditAttributeTypeView>>();

            ForRequestedType<ModulePresenter<IAttributeValueListView>>().TheDefaultIsConcreteType
                <AttributeTypeValueListPresenter<IAttributeValueListView>>();

            ForRequestedType<ModulePresenter<IProductTypeListView>>().TheDefaultIsConcreteType
                <ProductTypeListPresenter<IProductTypeListView>>();
            ForRequestedType<ModulePresenter<IEditProductTypeView>>().TheDefaultIsConcreteType
                <EditProductTypePresenter<IEditProductTypeView>>();

            ForRequestedType<ModulePresenter<IAttributeListView>>().TheDefaultIsConcreteType
                <AttributeListPresenter<IAttributeListView>>();
            ForRequestedType<ModulePresenter<IEditAttributeView>>().TheDefaultIsConcreteType
                <EditAttributePresenter<IEditAttributeView>>();
        }     
    }
}

